#include "plural.h"
#include "../btree/bplustree.h"

int test1()
{
	jieningPlural tmpa(1.1, 1.1);
	jieningPlural tmpb(-2.5, -5.2);

	cout<<"tmpa="<<tmpa<<" "<<endl;
	cout<<"tmpb="<<tmpb<<" "<<endl;
	cout<<tmpa.toStringMG()<<endl;
	cout<<tmpb.toStringMG()<<endl;
	cout<<tmpa.toStringMGd()<<endl;
	cout<<tmpb.toStringMGd()<<endl;

	cout<<"tmpc = tmpa+tmpb"<<endl;
	jieningPlural tmpc = tmpa+tmpb;
	cout<<tmpc.toString()<<endl;
	cout<<tmpc.toStringMG()<<endl;
	cout<<tmpc.toStringMGd()<<endl;

	cout<<"tmpc = tmpa+tmpb"<<endl;
	tmpc = tmpa-tmpb;
	cout<<tmpc.toString()<<endl;
	cout<<tmpc.toStringMG()<<endl;
	cout<<tmpc.toStringMGd()<<endl;

	cout<<"tmpc = tmpa*tmpb"<<endl;
	tmpc = tmpa*tmpb;
	cout<<tmpc.toString()<<endl;
	cout<<tmpc.toStringMG()<<endl;
	cout<<tmpc.toStringMGd()<<endl;

	cout<<"tmpc = tmpa/tmpb"<<endl;
	tmpc = tmpa/tmpb;
	cout<<tmpc.toString()<<endl;
	cout<<tmpc.toStringMG()<<endl;
	cout<<tmpc.toStringMGd()<<endl;

	cout<<(tmpa<tmpb ? "tmpa<tmpb" : "tmpa>=tmpb")<<endl;
	cout<<(tmpa<tmpc ? "tmpa<tmpc" : "tmpa>=tmpc")<<endl;
	cout<<(tmpb<tmpc ? "tmpb<tmpc" : "tmpb>=tmpc")<<endl;

	return 0;
}

//*
int test2()
{	
	double insertkeys[256] = {
		2,4,6,8,10,12,14,16,18,20,
		1,3,5,7,9,11,13,15,17,19,
		-2,-4,-6,-8,-10,-12,-14,-16,-18,-20,
		-1,-3,-5,-7,-9,-11,-13,-15,-17,-19,
		0,100,200,300,400,500,600,700,800,900,
		50,150,250,350,450,550,650,750,850,950,
	};

	typedef	struct jieningBtreeKVpair<jieningPlural, int> insertkvp;

	jieningBplustree<jieningPlural, int> theBtreeRoot(4);

	for(int loop=0; loop<50;loop+=2)
	{
		cout<<"add key["<<loop<<"] = "<<insertkeys[loop]<<endl;
		jieningPlural tmpk((insertkeys[loop]), (insertkeys[loop+1]));
		if(theBtreeRoot.addKvp(new insertkvp(tmpk)))
		{
			cout<<"add key["<<loop<<"] = "<<tmpk<<" succ"<<endl;

			//theBtreeRoot.doPrint();
			//bool checkre = theBtreeRoot.doTreeCheck();
			//cout<<"theBtreeRoot.doTreeCheck return "<<(checkre? "true": "false")<<endl;
		}
		else
		{
			cout<<"add key["<<loop<<"] = "<<tmpk<<" fail"<<endl;
		}
	}

	//return 0;
	theBtreeRoot.doPrint();
	bool checkre = theBtreeRoot.doTreeCheck();
	cout<<"theBtreeRoot.doTreeCheck return "<<(checkre? "true": "false")<<endl;

	return 0;
}
//*/

int main()
{
	test1();
	test2();
	return 0;
}
